/* GUI CONVERTED from rwworlc.p (converter v1.76) Thu Apr 25 19:01:29 2002 */
/* rwworlc.p - Copy routing to operations (wr_route)                          */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.3.1.2 $                                                           */
/*V8:ConvertMode=Maintenance                                                  */
/* Revision: 8.6E    Modified: 08/05/98      BY: *H1H4* Dana Tunstall         */
/* Revision: 9.1     Modified: 08/12/00      BY: *N0KP* Mark Brown            */
/* $Revision: 1.3.1.2 $   BY: Jean Miller        DATE: 04/16/02  ECO: *P05H*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

define shared temp-table temp-wo_mstr no-undo like wo_mstr
   use-index wo_nbr.
define shared temp-table temp-wr_route no-undo like wr_route
   use-index wr_lot.

define shared variable wo_recno as recid.
define shared variable eff_date as date.
define variable qty like wo_mstr.wo_qty_ord no-undo.
define variable routing like wo_mstr.wo_routing no-undo.

find temp-wo_mstr no-lock
   where recid(temp-wo_mstr) = wo_recno no-error.

if available temp-wo_mstr then do:

   qty = max (wo_qty_ord - wo_qty_comp - wo_qty_rjct,0).

   routing = wo_routing.
   if routing = "" then routing = wo_part.

   for each ro_det no-lock where
           ro_routing = routing
      and (ro_start = ? or ro_start <= wo_rel_date)
      and (ro_end = ? or ro_end >= wo_rel_date):

      find temp-wr_route where wr_lot = wo_lot and wr_op = ro_op no-error.
      if not available temp-wr_route
      then
         create temp-wr_route.

      assign
         wr_nbr = wo_nbr
         wr_lot = wo_lot
         wr_part = wo_part
         wr_op = ro_op
         wr_std_op = ro_std_op
         wr_desc = ro_desc
         wr_wkctr = ro_wkctr
         wr_mch = ro_mch
         wr_setup = ro_setup
         wr_run = ro_run
         wr_move = ro_move
         wr_qty_ord = qty
         wr_tool = ro_tool
         wr_vend = ro_vend
         wr_yield_pct = ro_yield
         wr_setup_men = ro_setup_men
         wr_men_mch = ro_men_mc
         wr_tran_qty = ro_tran_qty
         wr_mch_op = ro_mch_op
         wr_queue = ro_queue
         wr_wait = ro_wait
         wr_milestone = ro_milestone
         wr_sub_lead = ro_sub_lead.

   end.

end.
